home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 5 / BBS in a Box -Volume V (BBS in a Box) (April 1992).iso / Files / Prog / M / MPWGCC (Misc).cpt / Tests / tak.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  334 b   |  24 lines  |  [TEXT/MPS ]

  1. /* Tak in C */
  2.  
  3. #include "defns.h"
  4.  
  5. main()
  6. {
  7.     int starttime = clock();
  8.  
  9.     printf("%d\n", tak(18, 12, 6));
  10.     printf("%d/%d seconds\n", clock() - starttime, CLK_TCK);
  11. }
  12.  
  13. tak(x, y, z)
  14. int x, y, z;
  15. {
  16.     if (y >= x) {
  17.     return z;
  18.     } else {
  19.     return (tak(tak(x - 1, y, z),
  20.             tak(y - 1, z, x),
  21.             tak(z - 1, x, y)));
  22.     }
  23. }
  24.